/*
	怪物生成器，各个场景的怪物统一在这里生成获取
*/
package gameLogic

import "github.com/sirupsen/logrus"

//保存了场景会生成的怪物列表
var sceneEnemyList map[string][]Enemy

func init() {
	sceneEnemyList = make(map[string][]Enemy)

	sceneEnemyList[kDefaultScene] = make([]Enemy, 0)

}

func AddEnemy(scene string, enemy Enemy) {
	sceneEnemyList[scene] = append(sceneEnemyList[scene], enemy)
}

func GetRandomEnemy(scene string) *Enemy {
	if _, ok := sceneEnemyList[scene]; !ok {
		logrus.Errorf("cant find scene:%s 's enemy! please check!", scene)
		return nil
	}

	enemySize := len(sceneEnemyList[scene])
	if enemySize == 0 {
		logrus.Errorf("scene: %s has no enemy! pleace check!", scene)
		return nil
	}

	//随机返回一个敌人
	return &sceneEnemyList[scene][GetRandIdx(enemySize)]
}
